<template>
    <div class="app-container">
        <el-row :gutter="20">
            <splitpanes :horizontal="this.$store.getters.device === 'mobile'" class="default-theme">
                <pane size="84">
                    <el-col>
                        <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
                            <el-form-item label="版本号" prop="id">
                                <el-input v-model="queryParams.id" placeholder="请输入版本号" clearable
                                    @keyup.enter.native="handleQuery" />
                            </el-form-item>
                            <el-form-item label="产品代号" prop="code">
                                <el-input v-model="queryParams.code" placeholder="请输入产品代号" clearable
                                    @keyup.enter.native="handleQuery" />
                            </el-form-item>
                            <el-form-item label="花色" prop="color">
                                <el-input v-model="queryParams.color" placeholder="请输入花色" clearable
                                    @keyup.enter.native="handleQuery" />
                            </el-form-item>
                            <el-form-item label="尺寸" prop="dimension">
                                <el-input v-model="queryParams.dimension" placeholder="请输入尺寸" clearable
                                    @keyup.enter.native="handleQuery" />
                            </el-form-item>
                            <el-form-item label="花色主题" prop="theme">
                                <el-input v-model="queryParams.theme" placeholder="请输入花色主题" clearable
                                    @keyup.enter.native="handleQuery" />
                            </el-form-item>


                            <el-form-item>
                                <el-button type="primary" icon="el-icon-search" size="mini"
                                    @click="handleQuery">搜索</el-button>
                                <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
                            </el-form-item>
                        </el-form>

                        <el-row :gutter="10" class="mb8">
                            <el-col :span="1.5">
                                <el-button type="primary" plain icon="el-icon-plus" size="mini"
                                    @click="handleAdd">新增</el-button>
                            </el-col>
                            <el-col :span="1.5">
                                <el-button type="warning" plain icon="el-icon-download" size="mini"
                                    @click="handleExport">导出</el-button>
                            </el-col>
                            <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
                        </el-row>

                        <el-table :data="detailedData" :row-class-name="rowClassName" v-loading="loading" @selection-change="handleSelectionChange">
                            <!-- <el-table-column type="selection" width="55" align="center" /> -->
                            <el-table-column prop="图片" align="center" label="图片">
                              <template slot-scope="scope">
                                <image-preview :src="scope.row.图片" :width="50" :height="50" />
                              </template>
                            </el-table-column>
                            <el-table-column align="center" label="版本号" prop="id" />
                            <el-table-column align="center" label="产品代号" prop="code" />
                            <el-table-column align="center" label="花色" prop="color" />
                            <el-table-column align="center" label="花色主题" prop="theme" />
                            <el-table-column align="center" label="一出几" prop="number" />
                            <el-table-column align="center" label="尺寸" prop="dimension" />
                            <el-table-column align="center" label="录入日期" prop="requestDate" />
                            <el-table-column align="center" label="备注" prop="remark" />
                            <el-table-column label="操作" align="center" width="150px" fixed="right">
                                <template slot-scope="scope">
                                    <el-button size="mini" type="text" icon="el-icon-edit"
                                        @click="handleUpdate(scope.row)">修改</el-button>
                                    <el-button size="mini" type="text" icon="el-icon-delete"
                                        @click="handleDelete(scope.row)">删除</el-button>
                                </template>
                            </el-table-column>
                        </el-table>

                        <pagination :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
                            @pagination="getList" />

                    </el-col>
                </pane>
            </splitpanes>
        </el-row>
        <el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body>
            <el-form ref="form" :model="form" :rules="rules" label-width="100px">
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="版本号" prop="id">
                            <el-input v-model="form.id" placeholder="请输入版本号" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="产品代号" prop="code">
                            <el-input v-model="form.code" placeholder="请输入产品代号" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="花色" prop="color">
                            <el-input v-model="form.color" placeholder="请输入花色" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="花色主题" prop="theme">
                            <el-input v-model="form.theme" placeholder="请输入花色主题" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="一出几" prop="number">
                            <el-input v-model="form.number" placeholder="请输入一出几" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="尺寸" prop="dimension">
                            <el-input v-model="form.dimension" placeholder="请输入尺寸" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="录入日期" prop="requestDate">
                            <el-input v-model="form.requestDate" placeholder="请输入录入日期" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="24">
                        <el-form-item label="备注" prop="remark">
                            <el-input v-model="form.remark" placeholder="请输入备注" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="图片" prop="图片">
                            <ImageUpload v-model="form.图片" :limit="1"></ImageUpload>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button type="primary" @click="submitForm">确 定</el-button>
                <el-button @click="cancel">取 消</el-button>
            </div>
        </el-dialog>
    </div>
</template>

<script>
import { Splitpanes, Pane } from "splitpanes";
import "splitpanes/dist/splitpanes.css";
export default {
    components: { Splitpanes, Pane },
    data() {
        return {
            // 标题
            title: null,
            // 总条数
            total: 0,
            // 打开弹出框
            open: false,
            // 表格
            form: {},
            // 校验
            rules: {},

            detailedData: [{
                id: '24582#',
                code: 'HZ-YL0750108-P',
                color: 'TL155#',
                theme:'水果',
                number: '1',
                dimension: '',
                requestDate:'2024-1-25',
                remark: '底花',
                图片:'',
            }, {
                id: '24587#',
                code: 'HZ-YL597066',
                color: '3224#D',
                theme:'水果',
                number: '4',
                dimension: '',
                requestDate:'2024-1-25',
                remark: '连体新模14',
                图片:'',
            }, {
                id: '24590#',
                code: 'HZ-YL010115',
                color: 'TL326#',
                theme:'水果',
                number: '1',
                dimension: '',
                requestDate:'2024-1-25',
                remark: '满版',
                图片:'',
            }, {
                id: '24591#',
                code: 'HZ-YL28315',
                color: 'TL326#',
                theme:'水果',
                number: '2',
                dimension: '',
                requestDate:'2024-1-25',
                remark: '底花',
                图片:'',
            }, {
                id: '24592#',
                code: 'HZ-YL13915',
                color: '3137#',
                theme:'水果',
                number: '1',
                dimension: '',
                requestDate:'2024-1-25',
                remark: '满版',
                图片:'',
            }],


            defaultProps: {
                children: 'children',
                label: 'label'
            },
            queryParams: {
                pageNum: 1,
                pageSize: 10,
            },
            showSearch: true,
            single: false,
            multiple: false,
            loading: false,
        }
    },
    mounted() {
        this.handleNodeClick(this.parentAccountName[0].children[0])
    },
    methods: {
        //显示高亮
        rowClassName({ row }) {
          return row.id === this.id ? 'selected-row' : ''; // 判断是否选中
        },
        filterNode(value, data) {
            if (!value) return true;
            return data.label.indexOf(value) !== -1;
        },
        handleNodeClick(data) {

        },
        submitForm() {
            this.open = false;
        },
        cancel() { this.open = false; },
        handleQuery() {
            this.loading = false;
        },
        resetQuery() {
        },
        handleAdd() {
            this.title = '新增'
            this.open = true;
            this.isEdit = false;
        },
        handleUpdate(row) {
            this.title = '编辑'
            this.open = true;
            this.isEdit = false;
            this.form = row;
        },
        handleDelete() { },
        handleExport() { },
        handleSelectionChange(selection) {
            this.ids = selection.map((item) => item.userId);
            this.single = selection.length !== 1;
            this.multiple = !selection.length;
        },
    },

}
</script>

<style>
.selected-row {
  background-color: yellow !important;
  /* 选中行的背景颜色 */
}
</style>